<?php defined('SYSPATH') OR die('No direct access allowed.');

class Contcategory_Controller extends Viewbase_Controller{
	
	public function __construct(){
	
		$this->modelname='contcategory';	
		$this->controllername='contcategory';
		$this->orderby=array('title'=>'');
		$this->parent_column='';
		$this->forms=array();
		parent::__construct();	
	}
	
	public function __postprocess_model($model){
		
		if($this->input->post('formtype')=='multiple'){
			$model->delete();
			$type=$this->input->post('type');
			foreach($this->input->post('titlearray') as $title){
					if($title!="" && ! $model->title_allready_exists($title, $type)){
					$model=ORM::factory($this->modelname);
					$model=$this->__post_to_model($model);
					$model->title=$title;
					$model->save();
				}
			}
		}
		
	}	
}